#coding=utf-8
from django.db import models

class SeqFasta(models.Model):
  gi = models.CharField(max_length=20, unique=True)
  description = models.CharField(max_length=100, blank=True, null=True)
  seq = models.CharField(max_length=20 )
  
  created_at = models.DateTimeField(auto_now_add=True)
  
  def __unicode__(self):
    return self.description[:20]
  
  def summery_seq(self):
      return self.seq[:10] + '...' + self.seq[-10:]

class SsrRecord(models.Model):
  seq = models.ForeignKey('SeqFasta')
  
  motif = models.CharField(max_length=20)
  len_motif = models.PositiveIntegerField()
  
  n = models.PositiveIntegerField()
  
  start = models.PositiveIntegerField()
  end = models.PositiveIntegerField()
  
  is_perfect = models.BooleanField(default=False)
  perfect_motif = models.CharField(max_length=100, blank=True, null=True)
  
  created_at = models.DateTimeField(auto_now_add=True)
  
  def __unicode__(self):
    return '%s:(%s)^%i'%(self.seq.gi, self.motif, self.n)
